package com.advert;

import com.advert.mqtt.client.EmqClient;
import com.advert.mqtt.client.EmqClient2;
import com.advert.mqtt.client.EmqClient3;
import com.advert.mqtt.properties.MqttProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import javax.annotation.PostConstruct;

/**
 * 启动程序
 * 
 * @author cabinet
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class MqttApplication
{

    public static void main(String[] args) {
        SpringApplication.run(MqttApplication.class, args);
    }

    @Autowired
    private EmqClient emqClient;
    @Autowired
    private EmqClient2 emqClient2;
    @Autowired
    private EmqClient3 emqClient3;

    @Autowired
    private MqttProperties properties;

    @PostConstruct
    public void init() {
        // 连接服务端
        emqClient.connect(properties.getUsername(), properties.getPassword());
        emqClient2.connect(properties.getUsername(), properties.getPassword());
        emqClient3.connect(properties.getUsername(), properties.getPassword());
    }
}
